import { ScrollView, View, Text, Image } from '@tarojs/components';
import React, { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import { connect } from 'react-redux';
import './index.less';
import * as T from './types';
import actions from './actions';
import { store2Props } from './selectors';

actions().actions.loadReducer();
// @ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class Index extends Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {
      questionDetail: Taro.getStorageSync('questionDetail') || {}
    };
  }

  componentDidMount() { }

  componentDidShow() { }

  componentWillUnmount() {
    this.props.actions.clean();
  }

  render() {
    let { questionDetail } = this.state;
    return (
      <ScrollView className="packageARepair" scrollY>
        <View className='title'>
          <Text className='titles'>
            {questionDetail.investigationName}
          </Text>
        </View>
        <View className='content'>
          <Text className='contents'>
            &emsp;&emsp;{questionDetail.investigationDescription}
          </Text>
        </View>
        <View className="bottom">
          <View className="btn_box">
            <Text className='btn-release'
              onClick={() => {
                Taro.navigateTo({
                  url: '/pages/package-A/question-survery/detail/index'
                })
              }}
            >{questionDetail.type == 1 ? '查看已答' : '开始答题'}</Text>
          </View>
        </View>
      </ScrollView>
    );
  }
}
